<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib uri="http://shiro.apache.org/tags" prefix="shiro" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="${root}/resources/css/pintuer.css">
<link rel="stylesheet" href="${root}/resources/css/admin.css">
<script src="${root}/resources/js/jquery.js"></script>
<script src="${root}/resources/js/pintuer.js"></script>
</head>
<body>
<div class="panel admin-panel">
  <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>添加角色</strong></div>
  <div class="body-content">
    <form method="post" class="form-x" action="${root}/admin/role/add">
      <div class="form-group">
        <div class="label">
          <label>角色名称</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="" name="rolename" data-validate="required:请输入角色名" />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>角色描述</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="" name="roledesc" data-validate="required:请输入角色描述" />
          <div class="tips"></div>
        </div>
      </div>
      <if condition="$iscid eq 1">
        <div class="form-group">
          <div class="label">
            <label>角色权限：</label>
          </div>
          <div class="field" style="padding-top:8px;">
            <c:forEach items="${pList}" var="p">
              <c:if test="${p.id ne 9}">
                <input name="ps" value="${p.id}"  type="checkbox" />${p.permissionname}
              </c:if>
            </c:forEach>
            <%--首页 <input id="ishome"  type="checkbox" />
            推荐 <input id="isvouch"  type="checkbox" />
            置顶 <input id="istop"  type="checkbox" />--%>
          </div>
        </div>
      </if>
      <div class="clear"></div>
      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <button class="button bg-main icon-check-square-o" type="submit"> 提交</button>
        </div>
      </div>
    </form>
  </div>
</div>
  <script>
      $(
          function(){
              var checkBoxAll =$("input[name^='checkbox_']");//获取前缀为checkbox_的所有多选框对象
              var checkArray=${pList};//获取多选框需要回显得对应的值集合
              console.info("checkArray=",checkArray);
              for(var i=0;i<checkArray.length;i++){//
                  //获取所有复选框对象的value属性，然后，用checkArray[i]和他们匹配，如果有，则说明他应被选中
                  $.each(checkBoxAll,function(j,checkbox){
                      //获取复选框的value属性
                      var checkValue=$(checkbox).val();
                      if(checkArray[i]==checkValue){
                          $(checkbox).attr("checked",true);
                      }
                  })
              }
          });
  </script>
</body></html>